﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Presenter_SSResourceManager;

namespace WebView_SSResourceManager.UserPages
{
    public partial class Profile : System.Web.UI.Page, IViewProfile
    {
        PresenterProfile _presenter;

        protected void Page_Load(object sender, EventArgs e)
        {
            _presenter = new PresenterProfile(this);
            _presenter.FillFieldToEdit();
        }

        protected void btnEdit_OnClick(object sender, EventArgs e)
        {
            Response.Redirect(string.Format("EditProfile.aspx?{0}", GetUserId().ToString()));
        }

        public Guid GetUserId()
        {
            return Guid.Parse(Server.HtmlEncode(Request.Cookies["UID"].Value));
        }

        public void SetDataForUser(Model_SSResourceManager.User user)
        {
            lblLoginText.Text = user.Login;
            lblFirstNameText.Text = user.FirstName;
            lblLastNameText.Text = user.LastName;
            lblEmailText.Text = user.Email;
            lblSkypeText.Text = user.Skype;
            lblStatusText.Text = user.Status.ToString();
            lblMessageTimeSpanText.Text = user.MessageTimeSpan.ToString();
        }
    }
}